RAIS  3.2
C:/Projekte/RAIS/Specific Masks/SearchTool.aspx.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Data;
00030 using System.Configuration;
00031 using System.Collections;
00032 using System.Collections.Generic;
00033 using System.Web;
00034 using System.Web.Security;
00035 using System.Web.UI;
00036 using System.Web.UI.WebControls;
00037 using System.Web.UI.WebControls.WebParts;
00038 using System.Web.UI.HtmlControls;
00039 using System.Linq;
00040 
00041 using RAIS.ApplicationLogicLayer;
00042 using RAIS.Common;
00043 using RAIS.Common.DynamicMaskManagement;
00044 using RAIS.Common.UserManagement;
00045 
00046 
00047 namespace RAIS.UI.SpecificMasks
00048 {
00052     public partial class SearchTool : System.Web.UI.Page
00053     {
00054         //*********************************************************************
00055         #region Properties
00056 
00059         protected UserData CurrentUser
00060         {
00061             get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; }
00062         }
00066                 public string SelectedSearchItem
00067                 {
00068                         get
00069                         {
00070                                 Dictionary<string, string> searchItems =
00071                                         UI.Common.SearchManagement.GetSearchItems(this.Page, false);
00072                                 if (searchItems != null && searchItems.ContainsKey(this.DDLsearchby.SelectedValue))
00073                                         return searchItems[this.DDLsearchby.SelectedValue];
00074                                 else
00075                                         return string.Empty;
00076                         }
00077                 }
00081                 public SearchDefinition SelectedSearchDefinition
00082                 {
00083                         get
00084                         {
00085                                 Dictionary<string, SearchDefinition> searchDefinitions =
00086                                         UI.Common.SearchManagement.GetSearchDefinitionsBySearchItem(this.Page, this.SelectedSearchItem, false);
00087                                 if (searchDefinitions != null && searchDefinitions.ContainsKey(this.DDLsearchfor.SelectedValue))
00088                                         return searchDefinitions[this.DDLsearchfor.SelectedValue];
00089                                 else
00090                                         return null;
00091                         }
00092                 }
00093                 #endregion
00094                 //*********************************************************************
00095                 #region Event handlers
00096         protected void Page_PreLoad(object sender, EventArgs e)
00097         {
00098             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00099         }
00106         protected void Page_Load(object sender, EventArgs e)
00107         {
00108                         this.Response.Cache.SetNoStore();
00109                         if (this.CurrentUser == null)
00110                 UI.Common.AccessManagement.SignOut(this);
00111                         this.LBLresult.Text = string.Empty;
00112 
00113             if (!this.IsPostBack)
00114             {
00115                 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name;
00116 
00117                 this.InitializeSearchItems();
00118                 this.SetFocus(this.DDLsearchby);
00119                 this.LBLtools.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT;
00120                 UI.Common.PageManagement.InitializePageTreeForCategory(this, this.TreeView1, RAIS.Common.Constants.CATEGORY_NAME_TOOLS);
00121 
00122                 //                              this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest);
00123 
00124                 RAIS.UI.Common.PageManagement.SelectTreeNode(TreeView1.Nodes[0].ChildNodes, "_URL_PREFIX~/SearchTool.aspx");
00125                 TreeView1.SelectedNodeStyle.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT;
00126             }
00127             UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault);
00128         }
00134                 protected void Page_Init(object sender, EventArgs e)
00135         {
00136             Common.PageManagement.SetScrolableListBox(LBresults, this, true);
00137         }
00143                 protected void DDLsearchby_SelectedIndexChanged(object sender, EventArgs e)
00144                 {
00145                         this.OnSetSearchItemValue();
00146                         this.SetControlsProperties();
00147                 }
00153                 protected void DDLsearchfor_SelectedIndexChanged(object sender, EventArgs e)
00154                 {
00155                         this.OnSetSearchDefinitionValue();
00156                         this.SetControlsProperties();
00157                 }
00163                 protected void BTNsearch_Click(object sender, EventArgs e)
00164                 {
00165                         bool success = false;
00166                         string resultMessage = string.Empty;
00167                         Search search = new Search();
00168             search.UserID = CurrentUser.ID;
00169                         this.LBresults.Items.Clear();
00170 
00171                         search.SearchDefinition = this.SelectedSearchDefinition;
00172                         search.SearchText = this.TXTincludingtext.Text;
00173                         success = RAIS.ApplicationLogicLayer.SearchManagement.SearchInDB(search, ref resultMessage);
00174 
00175                         if (success)
00176                         {
00177                                 Dictionary<int, string> searchResult = search.SearchResult;
00178 
00179                                 if (searchResult != null)
00180                                         foreach (KeyValuePair<int, string> kvp in searchResult)
00181                                                 this.LBresults.Items.Add(new ListItem(kvp.Value, kvp.Key.ToString()));
00182                                 this.SetControlsProperties();
00183                         }
00184                         else
00185                         {
00186                                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00187                                                                                                                                                 resultMessage,
00188                                                                                                                                                 success);
00189                         }
00190                 }
00196                 protected void LBresults_SelectedIndexChanged(object sender, EventArgs e)
00197                 {
00198                         int rowID = int.Parse(this.LBresults.SelectedValue);
00199 
00200                         DynamicMaskData dynamicMaskData = DynamicMaskManagement.GetDynamicMaskData(
00201                                   this.SelectedSearchDefinition.MaskID
00202                                 , this.SelectedSearchDefinition.TabID
00203                                 , rowID
00204                                 , this.CurrentUser
00205                                 , false);
00206 
00207                         string reference = UI.Common.DynamicMaskManagement.GetDynamicMaskReference(
00208                                   dynamicMaskData
00209                                 , this.SelectedSearchDefinition.MaskID
00210                                 , this.SelectedSearchDefinition.TabID
00211                                 , rowID
00212                                 , rowID
00213                                 , false);
00214                         Response.Redirect(reference);
00215                 }
00222         protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
00223         {
00224             UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1);
00225         }
00232         protected void LBTNlogout_Click(object sender, EventArgs e)
00233         {
00234             UI.Common.AccessManagement.SignOut(this);
00235         }
00236         #endregion
00237                 //*********************************************************************
00238                 #region Private helper methods
00239 
00242                 private void InitializeSearchItems()
00243                 {
00244                         UI.Common.SearchManagement.InitializeSearchItems(this.DDLsearchby);
00245                         this.OnSetSearchItemValue();
00246                         this.SetControlsProperties();
00247                 }
00251                 private void OnSetSearchItemValue()
00252                 {
00253                         if (!string.IsNullOrEmpty(this.SelectedSearchItem))
00254                                 UI.Common.SearchManagement.InitializeSearchDefinitionsBySearchItem(this.DDLsearchfor, this.SelectedSearchItem);
00255                         else
00256                                 this.DDLsearchfor.Items.Clear();
00257 
00258                         this.OnSetSearchDefinitionValue();
00259                 }
00263                 private void OnSetSearchDefinitionValue()
00264                 {
00265                         this.TXTincludingtext.Text = string.Empty;
00266                         this.LBresults.Items.Clear();
00267                 }
00271                 private void SetControlsProperties()
00272                 {
00273                         this.BTNsearch.Enabled = !string.IsNullOrEmpty(this.SelectedSearchItem)
00274                                 && this.SelectedSearchDefinition != null;
00275                         this.LBresults.Enabled = (this.LBresults.Items.Count != 0);
00276                 }
00277         #endregion
00278     }
00279 }